package com.broad.commerce.code.services;

import com.broad.commerce.code.models.EntityModuleDTO;
import com.broad.commerce.code.services.base.BusinessModuleService;
import com.broad.commerce.code.services.base.JdbcModuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author stephen
 * @version V1.0
 * @date 2022-02-09 11:13
 * @description: AutoCodeService
 **/
@Service
public class AutoCodeService {
	@Autowired
	private JdbcModuleService jdbcModuleService;
	@Autowired
	private BusinessModuleService businessModuleService;

	public void batchCreateJdbcModuleFiles(List<EntityModuleDTO> entityModuleDTOs) {
		if (entityModuleDTOs.isEmpty()) {
			return;
		}
		entityModuleDTOs.forEach(this::createJdbcModuleFiles);
	}

	public void createJdbcModuleFiles(EntityModuleDTO entityModuleDTO) {
		this.jdbcModuleService.createModuleFiles(entityModuleDTO);
	}

	public void batchCreateBusinessModuleFiles(List<EntityModuleDTO> entityModuleDTOs) {
		if (entityModuleDTOs.isEmpty()) {
			return;
		}
		entityModuleDTOs.forEach(this::createBusinessModuleFiles);
	}

	public void createBusinessModuleFiles(EntityModuleDTO entityModuleDTO) {
		this.businessModuleService.createModuleFiles(entityModuleDTO);
	}
}
